import { ApiProperty } from '@nestjs/swagger';
import { IsString, IsOptional, IsDateString, IsArray, ValidateNested, IsEnum, IsNumber } from 'class-validator';
import { Type } from 'class-transformer';
import { CreateBettingDto } from './create-betting.dto';

/**
 * 创建比赛DTO
 */
export class CreateMatchDto {

  @ApiProperty({ 
    description: '开赛时间',
    example: '2025-07-14T23:00:00.000Z' 
  })
  @IsDateString()
  matchTime: string;

  @ApiProperty({ 
    description: '赛事名称',
    example: '分组' 
  })
  @IsString()
  leagueName: string;

  @ApiProperty({ 
    description: '主队名称',
    example: '埃尔维斯' 
  })
  @IsString()
  homeTeam: string;

  @ApiProperty({ 
    description: '客队名称',
    example: '瓦萨' 
  })
  @IsString()
  awayTeam: string;

  @ApiProperty({ 
    description: '主队队标URL',
    required: false 
  })
  @IsOptional()
  @IsString()
  homeTeamLogo?: string;

  @ApiProperty({ 
    description: '客队队标URL',
    required: false 
  })
  @IsOptional()
  @IsString()
  awayTeamLogo?: string;

  @ApiProperty({ 
    description: '外部ID',
    required: false 
  })
  @IsOptional()
  @IsString()
  externalId?: string;

  @ApiProperty({ 
    description: '胆推荐状态',
    example: 'none',
    enum: ['none', 'recommend_bold', 'recommend_stable'],
    required: false 
  })
  @IsOptional()
  @IsEnum(['none', 'recommend_bold', 'recommend_stable'])
  boldRecommendation?: string;

  @ApiProperty({ 
    description: '主队胜率',
    example: 65.5,
    required: false 
  })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  homeWinRate?: number;

  @ApiProperty({ 
    description: '客队胜率',
    example: 34.5,
    required: false 
  })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  awayWinRate?: number;

  @ApiProperty({ 
    description: '备注',
    example: '重要比赛',
    required: false 
  })
  @IsOptional()
  @IsString()
  remarks?: string;

  @ApiProperty({ 
    description: '投注选项列表',
    type: [CreateBettingDto],
    required: false 
  })
  @IsOptional()
  @IsArray()
  @ValidateNested({ each: true })
  @Type(() => CreateBettingDto)
  bettings?: CreateBettingDto[];
}